<?php

namespace Modules\Shop\Http\Controllers;

use HiCommon\Service\ShopAccountService;
use Illuminate\Support\Facades\Request;

class ShopAccountController extends BaseController
{

    /*商户资金账户信息*/
    public function account_info_page(){
        try {
            $n_shop_id = intval(shop_shop_id());
            $result = ShopAccountService::api_get_account_info($n_shop_id);
            echo_error($result);
            $arr_data = [
              'arr_data'=>$result['data']
            ];
            return view('shop::shop_user.account_info_page',$arr_data);
        }
        catch (\Exception $exception) {
            msg_error('fail-'.$exception->getMessage());
            return 'ok';
        }
    }

    /*修改商户资金账户信息*/
    public function account_info_update(){
        try {
            $arr_input = Request::input();
            $s_phone = shop_phone();

            /*只有主账号才能修改这样的敏感信息*/
            $n_ismaster = shop_user()->is_master;
            if($n_ismaster != 1){
                return hello_error('修改失败',[],'只有主账号才能进行这样的敏感操作');
            }

            //修改商户资金账户信息
            $result = ShopAccountService::api_edit_account_info($s_phone,$arr_input);
            return  $result;
        }
        catch (\Exception $exception) {
            return hello_error('fail-'.$exception->getMessage(),[],$exception->getMessage());
        }
    }
}
